﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="DCOutwardEdit.aspx.cs" Inherits="Main_Inventory_DCOutwardEdit" Culture="en-GB" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="AjaxControl" %>
<%@ Register Src="~/User Controls/PageHeading.ascx" TagName="heading" TagPrefix="acc" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>DC Outward Edit</title>
    <link href="../../Styles/accounts.css" rel="stylesheet" type="text/css" />
      <script type="text/javascript" language="javascript">
        function DropdownDeliveryaddress() {
            var customerid = document.getElementById("DdlCustomer").value;
            if (customerid != "0") {
                var hidvalue = document.getElementById("hidDeliveryId").value;
                window.open('DeliveryAddress.aspx?customerid=' + customerid + '&control1=hidDeliveryId&control2=TxtDeliveryAddress&addid=' + hidvalue, 'myPopup', 'height=400,width=900,left=100,top=100,resizable=yes,scrollbars=yes,toolbar=no,status=no')
            }
            else {
                alert("Please Select Customer First !");
                return false;
            }
        }
         function GetQuantity(hidItemId, CtrlId, HidLocationId) {
            if (hidItemId != '' && parseFloat(hidItemId) > 0) {
                var ctrlIndex = HidLocationId.toString();
                var LocationIdandQty = document.getElementById(ctrlIndex).value;
                window.open('DCOutwardSaleQty.aspx?ItemId=' + hidItemId + '&CtrlId=' + CtrlId + '&HidLocationId=' + HidLocationId + '&LocationIdandQty=' + LocationIdandQty, '', 'width=700, height=400, resizable=0');
            }
            else {
                alert('Choose Item First');
                return false;
            }
        }

         function EnabledTabKey(id, e) {
            var keycode;
            if (window.event) {
                keycode = window.event.keyCode;
            }
            else if (e) {
                keycode = e.which;
            }
            else {
                return true;
            }

            if (keycode == 9) {
                // if is the tab key                
                return true;
            }
            else {
                return false;
            }
        }

          function CalculateAmtQtyRate() {
            var Count = document.getElementById("hcount").value;
            var TotalQty = 0;
            var rate = 0;
            var TotalAmount = 0;
            for (var i = 1; i <= Count; i++) {
                var Qty = document.getElementById("txtquantity" + i);
                var RateAmt = document.getElementById("txtrate" + i);

                var itemAmt = 0;
                if (Qty.value != '' && parseFloat(Qty.value) > 0) {
                    if (RateAmt.value != '' && parseFloat(RateAmt.value) > 0) {
                        itemAmt = parseFloat(Qty.value) * parseFloat(RateAmt.value);
                        TotalAmount += parseFloat(itemAmt);
                    }
                }
                document.getElementById("txtamount" + i).value = itemAmt;
            }

        }
        
           function checkItemRepetion(id) {
            var ddl = document.getElementById(id);
            var currentValue = ddl.options[ddl.selectedIndex].value;
            var Count = document.getElementById("hidControl").value;
            for (var i = 1; i <= Count; i++) {
                var previous = document.getElementById("ddlitems" + i);
                var previousValue = previous.options[previous.selectedIndex].value
                if (ddl != previous) {
                    if (currentValue == previousValue) {
                        alert('Please Select Unique Item');
                        ddl.selectedIndex = 0;
                        break;
                    }
                }
            }
            return true;
        }

        </script> 
</head>
<body>
    <form id="form1" runat="server">
   <asp:ScriptManager ID="ScriptManager1" runat="server">  </asp:ScriptManager>
    <div class="divmain" style="width: 95%; margin-left: 3%;">
        <acc:heading ID="pagehead" runat="server" HeadingText="DC Outward Edit" />
        <div style="margin-left: 10%; margin-right: 3%; width: 85%" align="center">
            <asp:Label ID="lblMsg" runat="server" Font-Bold="true"></asp:Label>
        </div>
     <asp:HiddenField ID="hcount" Value="2" runat="server" /> 
     <asp:HiddenField ID="hidCheckDelivery" runat="server" Value="True" />
     <asp:HiddenField ID="hidTRNID" runat="server" />
     <asp:HiddenField ID="hidTIDIDCollection" runat="server" />
        <table class="tablecontent" style="width: 100%">
            <tr>
                <td colspan="3" style="width: 100%;" class="headtd">DC Outward
                </td>
            </tr>
            <tr>
               <%--<asp:UpdatePanel ID="UpdatePanel1" runat="server">
                <ContentTemplate >--%>
                <td style="width: 35%;">                   
                    <table class="tablecontent" style="width:100%; margin-top:2px; height:80px;">
                        <tr>
                            <td style="width:30%">
                                DC Format<span style="color: Red">*</span>
                            </td>
                            <td style="width:70%">
                                <asp:DropDownList ID="ddldcformat" Enabled="false" runat="server" 
                                    ValidationGroup="V" onselectedindexchanged="ddldcformat_SelectedIndexChanged1" >
                                </asp:DropDownList>
                            </td>
                        </tr>

                        <tr>
                            <td >
                                DC No.<span style="color: Red">*</span>
                            </td>
                            <td >
                                <asp:TextBox ID="txtPrefix" runat="server" Enabled="false"  Width="45px" CssClass="input" onKeyPress="return false"
                                    onKeydown="return false"></asp:TextBox>
                                <AjaxControl:TextBoxWatermarkExtender ID="prefixWater" runat="server" TargetControlID="txtPrefix"
                                    WatermarkText="Prefix" WatermarkCssClass="watermark_textbox">
                                </AjaxControl:TextBoxWatermarkExtender>
                                <asp:TextBox ID="txtVoucher" runat="server" Enabled="false" Width="45px" CssClass="inputnumber" ValidationGroup="V"
                                    MaxLength="10" OnKeyPress="return Desable();"></asp:TextBox>
                                <AjaxControl:TextBoxWatermarkExtender ID="voucherWater" Enabled="false" runat="server" TargetControlID="txtVoucher"
                                    WatermarkText="Number" WatermarkCssClass="watermark_textbox">
                                </AjaxControl:TextBoxWatermarkExtender>
                                <asp:TextBox ID="txtSuffix" runat="server" Width="45px" Enabled="false" CssClass="input" onKeyPress="return false"
                                    onKeydown="return false"></asp:TextBox>
                                <AjaxControl:TextBoxWatermarkExtender ID="suffixWater"  runat="server" TargetControlID="txtSuffix"
                                    WatermarkText="Suffix" WatermarkCssClass="watermark_textbox">
                                </AjaxControl:TextBoxWatermarkExtender>
                            </td>
                        </tr>
                        
                        <tr>
                            <td>
                                Date <span style="color: Red">*</span>
                            </td>
                            <td>
                                <asp:TextBox ID="txtdate" Width="60px" runat="server" ValidationGroup="V"></asp:TextBox>
                                <asp:ImageButton ID="btnDate" runat="server" ImageUrl="~/Images/calendar.gif" />
                                <AjaxControl:CalendarExtender ID="cal" runat="server" PopupButtonID="btnDate" TargetControlID="txtdate"
                                    Format="dd/MM/yyyy">
                                </AjaxControl:CalendarExtender>
                                <AjaxControl:MaskedEditExtender ID="maskExt" runat="server" MaskType="Date" Mask="99/99/9999"
                                    TargetControlID="txtdate" CultureName="pt-BR">
                                </AjaxControl:MaskedEditExtender>
                                <AjaxControl:MaskedEditValidator ID="maskValid" runat="server" ControlExtender="maskExt"
                                    InvalidValueMessage="Invalid Date" Display="Dynamic" ValidationGroup="V"
                                    ControlToValidate="txtdate"></AjaxControl:MaskedEditValidator>
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ValidationGroup="V" Display="Dynamic"
                                 ControlToValidate="txtdate" ErrorMessage="*" SetFocusOnError="true"> </asp:RequiredFieldValidator>
                             
                            </td>
                        </tr>

                    </table>
                </td>
                <td style="width: 35%">
                    <table class="tablecontent" style="width: 100%; margin-top: 2px; height:80px;">
                        <tr>
                            <td style="width: 30%">
                                Customer <span style="color: Red">*</span>
                            </td>
                            <td style="width: 70%">
                                <asp:DropDownList ID="DdlCustomer" runat="server" ValidationGroup="V"
                                   onselectedindexchanged="DdlCustomer_SelectedIndexChanged" AutoPostBack="true"
                                 >
                                </asp:DropDownList>
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator2" InitialValue="0" ValidationGroup="V" runat="server" Display="Dynamic"
                                 ControlToValidate="DdlCustomer" ErrorMessage="*"  SetFocusOnError="true" > </asp:RequiredFieldValidator>
                                 <asp:HiddenField ID="hidDeliveryId" runat="server" />
                            </td>
                        </tr>

                        <tr>
                            <td>
                                Tax <span style="color: Red">*</span>
                            </td>
                            <td>
                                <asp:DropDownList ID="DdlTax" Width="200px" runat="server" ValidationGroup="V">
                                </asp:DropDownList>
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator3" ValidationGroup="V" InitialValue="0" runat="server" SetFocusOnError="true"
                                 ControlToValidate="DdlTax" ErrorMessage="*" Display="Dynamic" > </asp:RequiredFieldValidator>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Category <span style="color: Red">*</span>
                            </td>
                            <td>
                                <asp:DropDownList ID="DdlCategory" Width="200px" runat="server" ValidationGroup="V"
                                >
                                </asp:DropDownList>
                                 <asp:RequiredFieldValidator ID="RequiredFieldValidator4" ValidationGroup="V" InitialValue="0" runat="server" SetFocusOnError="true" 
                                 ControlToValidate="DdlCategory" ErrorMessage="*" Display="Dynamic" > </asp:RequiredFieldValidator>


                            </td>
                        </tr>
                    </table>
                </td>
                <td style="width: 30%">
                    <table class="tablecontent" style="width:100%; margin-top:2px; height:70px;">
                         <tr>
                            <td>
                                 <b>DeliveryAddress</b>
                            </td>
                        </tr>
                        <tr>
                            <td >
                                <asp:TextBox ID="TxtDeliveryAddress" TextMode="MultiLine" runat="server"></asp:TextBox>
                            </td>
                        </tr>
                         <tr>
                            <td>
                                  <asp:Button ID="BtnDeliveryAdd" runat="server" CssClass="button1" 
                                         Text="Select Delivery Address"  
                                        OnClientClick ="return DropdownDeliveryaddress()"
                                         CausesValidation="False">
                                    </asp:Button>
                            </td>
                        </tr>
                    </table>
                </td>
               <%-- </ContentTemplate>
                </asp:UpdatePanel>--%>
            </tr>
         </table>

        <div >
        <asp:HiddenField ID="hidTITID" runat="server" />
         <asp:HiddenField ID="hidtaxamt" runat="server" />
          <asp:HiddenField ID="hidLocationBillLevel" runat="server" />
          <asp:HiddenField ID="huomid" runat="server" />
              <table id="tblitem" runat="server" class="tablecontent" style="width: 100%; margin-top: 2px;">
                   
                        <tr>
                            <td style="width: 10%; border-right: 1px solid #818181; border-bottom: 1px solid #818181;
                                text-align: center; font-weight: bold" class="headtd">
                                <b>Item (s)</b>
                            </td>
                            <td style="width: 10%; border-right: 1px solid #818181; border-bottom: 1px solid #818181;
                                text-align: center; font-weight: bold" class="headtd">
                                <b>Unit</b>
                            </td>
                            <td style="width: 13%; border-right: 1px solid #818181; border-bottom: 1px solid #818181;
                                text-align: center; font-weight: bold" class="headtd">
                                <b>Quantity</b>
                            </td>
                            <td style="width: 10%; border-right: 1px solid #818181; border-bottom: 1px solid #818181;
                                text-align: center; font-weight: bold" class="headtd">
                                <b>Rate</b>
                            </td>
                            <td style="width: 10%; border-bottom: 1px solid #818181; text-align: center; font-weight: bold"
                                class="headtd">
                                <b>Amount</b>
                            </td>
                        </tr>
                       <%-- <tr>
                            <td align="center">
                                <asp:DropDownList ID="ddlitems1" runat="server" OnSelectedIndexChanged="ddlitems_OnSelectedIndexChanged"
                                    CssClass="dropdown" Width="95%" AutoPostBack="true">
                                </asp:DropDownList>
                                <asp:HiddenField ID="hidTITID1" runat="server" />
                            </td>
                            <td align="center">
                                <asp:TextBox ID="txtunit1" runat="server" OnKeyDown="return EnabledTabKey(this.ID,event);" CssClass="input" Style="width: 95%;" />
                                
                            </td>
                            <td align="center">
                                <asp:TextBox ID="txtquantity1" runat="server" CssClass="inputnumber" Style="width: 88%;"
                                  onblur="return CalculateAmtQtyRate();" OnKeyDown="return EnabledTabKey(this.ID,event);" />
                                <asp:Button ID="btnQtyBillLevel1" runat="server" Text="..." CssClass="button" Width="5%" />
                                <asp:HiddenField ID="hidLocationBillLevel1" runat="server" />
                            </td>
                            <td align="center">
                                <asp:TextBox ID="txtrate1" runat="server" CssClass="inputnumber" Style="width: 95%;"
                                    onblur="return CalculateAmtQtyRate();" OnKeyPress="return isNumberKey(this.ID,event);" /><asp:HiddenField
                                        ID="hidTaxRate1" runat="server" />
                            </td>
                            <td align="center">
                                <asp:TextBox ID="txtamount1" runat="server" CssClass="inputnumber" Style="width: 95%;"
                                    OnKeyDown="return EnabledTabKey(this.ID,event);" />
                                    <asp:HiddenField ID="hidtaxamt1" runat="server" />
                            </td>
                        </tr>
                        <tr>
                            <td align="center">
                                <asp:DropDownList ID="ddlitems2" runat="server" OnSelectedIndexChanged="ddlitems_OnSelectedIndexChanged"
                                    CssClass="dropdown" Width="95%" AutoPostBack="true">
                                </asp:DropDownList>
                                <asp:HiddenField ID="hidTITID" runat="server" />
                            </td>
                            <td align="center">
                                <asp:TextBox ID="txtunit2" CssClass="input" runat="server" Style="width: 95%;" OnKeyDown="return EnabledTabKey(this.ID,event);" /><asp:HiddenField
                                    ID="huomid2" runat="server" />
                            </td>
                            <td align="center">
                                <asp:TextBox ID="txtquantity2" runat="server" CssClass="inputnumber" Style="width: 88%;"
                                    onblur="return CalculateAmtQtyRate();" OnKeyDown="return EnabledTabKey(this.ID,event);" />
                                <asp:Button ID="btnQtyBillLevel2" runat="server" Text="..." CssClass="button" Width="5%" />
                               
                            </td>
                            <td align="center">
                                <asp:TextBox ID="txtrate2" runat="server" CssClass="inputnumber" Style="width: 95%;"
                                    onblur="return CalculateAmtQtyRate();" OnKeyPress="return isNumberKey(this.ID,event);" /><asp:HiddenField
                                        ID="hidTaxRate2" runat="server" />
                            </td>
                            <td align="center">
                                <asp:TextBox ID="txtamount2" runat="server" CssClass="inputnumber" Style="width: 95%;"
                                    OnKeyDown="return EnabledTabKey(this.ID,event);" /><asp:HiddenField ID="hidtaxamt2"
                                        runat="server" />
                            </td>
                        </tr>--%>
                    </table>

                      <table style="width: 100%; margin-bottom:10px;" align="right">
                        <tr>
                            <td align="left">
                                <asp:LinkButton ID="btnAddMore" runat="server" OnClick="btnAddMore_Click"
                                   CausesValidation="false" > <img src="../../Images/More.jpg" alt="Add New Row" /></asp:LinkButton>
                            </td>
                        </tr>
                    </table>

                      <table id="DeliveryDetails" runat="server" style="width: 100%; margin-top:20px;" class="tablecontent">
                        <tr>
                            <td class="headtd" style="width: 100%;" colspan="6">
                                <b>Delivery Details</b>
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 16%">
                                Mode Of Delivery
                            </td>
                            <td style="width: 16%">
                                <asp:TextBox ID="txtmodeofdelivery" CssClass="input" runat="server"></asp:TextBox>
                            </td>
                            <td style="width: 16%">
                                Freight Indicator
                            </td>
                            <td style="width: 16%">
                                <asp:TextBox ID="txtfreightindicator" CssClass="input" runat="server"></asp:TextBox>
                            </td>
                            <td style="width: 16%">
                                Transporter Name
                            </td>
                            <td style="width: 16%">
                                <asp:TextBox ID="txttransportername" CssClass="input" runat="server"></asp:TextBox>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Document No.
                            </td>
                            <td>
                                <asp:TextBox ID="txtdocumentno" CssClass="input" runat="server"></asp:TextBox>
                            </td>
                            <td>
                                Delivery Date <span style="color: Red">*</span>
                            </td>
                            <td>
                                <asp:TextBox ID="txtdeliverydate" Width="110px" runat="server"></asp:TextBox>
                                <asp:ImageButton ID="btnimage" runat="server" ImageUrl="~/Images/calendar.gif" />
                                <AjaxControl:CalendarExtender ID="CalendarExtender1" runat="server" PopupButtonID="btnimage"
                                    TargetControlID="txtdeliverydate" Format="dd/MM/yyyy">
                                </AjaxControl:CalendarExtender>
                                <AjaxControl:MaskedEditExtender ID="MaskedEditExtender1" runat="server" MaskType="Date"
                                    Mask="99/99/9999" TargetControlID="txtdeliverydate" CultureName="pt-BR">
                                </AjaxControl:MaskedEditExtender>
                                <AjaxControl:MaskedEditValidator ID="MaskedEditValidator1" runat="server" ControlExtender="maskExt"
                                    InvalidValueMessage="Invalid Date" IsValidEmpty="true" Display="Dynamic" ValidationGroup="V"
                                    ControlToValidate="txtdeliverydate"></AjaxControl:MaskedEditValidator>

                                <%-- <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" SetFocusOnError="true" 
                                    ControlToValidate="txtdeliverydate" ErrorMessage="*" Display="Dynamic" >
                                 </asp:RequiredFieldValidator>--%>


                            </td>
                            <td>
                                Vehicle No
                            </td>
                            <td>
                                <asp:TextBox ID="txtvehicleno" CssClass="input" runat="server"></asp:TextBox>
                            </td>
                        </tr>
                    </table>


                     <table id="OtherDetails" runat="server" style="width: 100%; margin-top: 10px; margin-bottom: 10px;" class="tablecontent">
                        <tr>
                            <td class="headtd" style="width: 100%;" colspan="6">
                                <b>Other Details</b>
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 16%">
                                Prepared By
                            </td>
                            <td style="width: 16%">
                                <asp:TextBox ID="txtpreparedby" CssClass="input" runat="server"></asp:TextBox>
                            </td>
                            <td style="width: 16%">
                                Checked By
                            </td>
                            <td style="width: 16%">
                                <asp:TextBox ID="txtcheckedby" CssClass="input" runat="server"></asp:TextBox>
                            </td>
                            <td style="width: 16%">
                                Authorised Signature
                            </td>
                            <td style="width: 16%">
                                <asp:TextBox ID="txtauthorisedsignature" CssClass="input" runat="server"></asp:TextBox>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Note
                            </td>
                            <td>
                                <asp:TextBox ID="txtnote" CssClass="input" runat="server"></asp:TextBox>
                            </td>
                            <td>
                                Remarks
                            </td>
                            <td colspan="3">
                                <asp:TextBox ID="txtremarks" CssClass="input" Height="20px" TextMode="MultiLine" runat="server" Width="96%"></asp:TextBox>
                            </td>
                        </tr>
                    </table>

                     <table style="width: 100%;">
                        <tr>
                            <td align="center">
                                <asp:Button ID="btnUpdate" Text="Update" runat="server" CssClass="button" ValidationGroup="V"
                                 OnClick="btnUpdate_Click"
                                 />
                                &nbsp;
                                <asp:Button ID="btnCancel" Text="Cancel" runat="server" CssClass="button" 
                                    onclick="btnCancel_Click" />
                            </td>
                        </tr>
                    </table>
            
        
        </div>
    </div>
    </form>
</body>
</html>
